//
//  ViewController.m
//  GCD
//
//  Created by MyMac on 15/9/29.
//  Copyright (c) 2015年 tongfang. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
  dispatch_queue_t queue=  dispatch_queue_create("hhhhh", DISPATCH_QUEUE_SERIAL );
   dispatch_sync(queue, ^{
       NSLog(@"3%@",[NSThread   currentThread]);
       dispatch_async(queue, ^{
           NSLog(@"1%@",[NSThread   currentThread]);
       });
   });
    //当前运行的任务都在主队列里面，这些主队列任务不完成，，，后面加入到主队列的任务就不会执行
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"4%@",[NSThread   currentThread]);
        NSLog(@"8");
        NSLog(@"9");
       // NSLog(@"%@",dispatch_get_main_queue());
        dispatch_sync(dispatch_get_main_queue(), ^{
            NSLog(@"6%@",[NSThread   currentThread]);

        });
    });

  
//    dispatch_async(queue, ^{
//         NSLog(@"7%@",[NSThread   currentThread]);
//    });
//    dispatch_async(dispatch_get_main_queue(), ^{
//        NSLog(@"5%@",[NSThread   currentThread]);
//    });
    NSLog(@"2");
 //   NSLog(@"7");
   
//    NSLog(@"5");
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
